﻿using MusicExplorer.Common;
using MusicExplorer.Model;
using MusicExplorer.ViewModel;
using MusicExplorer.ViewModel.Wrappers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Items Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234233

namespace MusicExplorer.View
{
    /// <summary>
    /// A page that displays a collection of item previews.  In the Split App this page
    /// is used to display and select one of the available groups.
    /// </summary>
    public sealed partial class TracksPageView : Page
    {
        public TracksPageView()
        {
            InitializeComponent();
            //m_navigationHelper.LoadState += m_navigationHelper_LoadState;
        }

        //async void m_navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        //{
        //    var navObj = (NavigationObject)e.NavigationParameter;
        //    DataContext = await TracksPageViewModel.CreateAsync<TracksPageViewModel>(navObj);
        //}
        private void PlayTrack(object sender, ItemClickEventArgs e)
        {
            var track = (TrackWrapper)e.ClickedItem;
            ((TracksPageViewModel)DataContext).CurrentTrackPlayed = ((Track)track.Entity).Mp3;
        }
    }
}
